package com.woniu.cq.mallorder.consumer;

import com.woniu.cq.mallorder.mapper.OrderMapper;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * @author Daniel
 * @version 1.0.0
 * @ClassName OrderConsumer
 * @Description TODO
 * @createTime 2020年09月23日 23:22:00
 */
@Component
@RocketMQMessageListener(topic = "topic",consumerGroup = "my-consumer")
public class OrderConsumer implements RocketMQListener {
    @Autowired
    private OrderMapper orderMapper;
    @Override
    public void onMessage(Object o) {
        Integer userId = Integer.parseInt(o.toString());
        LocalDateTime now = LocalDateTime.now();
        orderMapper.addLogs(userId,now);
    }
}
